﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="DefineGroupAdd.aspx.cs" Inherits="Business_Cisoft3G_ContactsManage_DefineGroupAdd" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>新增自定义组</title>

    <script type="text/javascript" src="../../../js/jquery-1.4.2.min.js"></script>

    <link href="../../../css/style.css" rel="stylesheet" type="text/css" />
    <link href="../../../css/font.css" rel="stylesheet" type="text/css" />

    <script type="text/javascript">
        $(document).ready(function() {
            //TreeView点击
            var o = $('a[href]');
            o.each(function() {
                var oo = $(this);
                oo.click(function() {
                    $('#s1').empty();
                    $.ajax({
                        type: "GET",
                        url: oo.attr('href'),
                        success: function(msg) {
                            $('#s1').append(msg);
                        }
                    });
                    return false;
                });
            });

            //点击查询按钮
            $('#btnSearch').click(function() {
                $('#s1').empty();
                $.ajax({
                    type: "GET",
                    url: 'GetContactsHandler.ashx?SearchType=' + $('#ddlSearchType option:selected').val() + '&Condition=' + $.trim($('#txtCondition').val()),
                    success: function(msg) {
                        if ($.trim(msg) != '') {
                            $('#s1').append(msg);
                        }
                    }
                });
            });


            //左边双击
            $("#s1").dblclick(function() {
                var alloptions = $("#s1 option");
                var so = $("#s1 option:selected");

                //so.get(so.length - 1).index == alloptions.length - 1 ? so.prev().attr("selected", true) : so.next().attr("selected", true);
                if ($("#s2").val() == null) {
                    $("#s2").append(so);
                }
                if ($("#s2").text() != null) {
                    if ($("#s2").text().indexOf(so.val()) == -1) {
                        $("#s2").append(so);
                    }
                    if ($("#s2").text().indexOf(so.val()) > -1) {
                    }
                }
                var strings = '';
                $('#s2 option').each(function() {
                    strings = strings + $(this).val() + ',';
                });

                $('#hih_right').attr('value', strings);
            });
            //右边双击
            $("#s2").dblclick(function() {
                var alloptions = $("#s2 option");
                var so = $("#s2 option:selected");
                //so.get(so.length - 1).index == alloptions.length - 1 ? so.prev().attr("selected", true) : so.next().attr("selected", true);
                if ($("#s1").text() == null) {
                    $("#s1").append(so);
                }
                if ($("#s1").text() != null) {
                    if ($("#s1").text().indexOf(so.val()) == -1) {
                        $("#s1").append(so);
                    }
                    else {
                        so.remove();
                    }
                }
                var strings = '';
                $('#s2 option').each(function() {
                    strings = strings + $(this).val() + ',';
                });

                $('#hih_right').attr('value', strings);
            });
            //选中右移
            $("#add").click(function() {
                var alloptions = $("#s1 option");
                if ($("#s1 option").val() != null) {
                    var so = $("#s1 option:selected");
                    if (so.length > 0) {
                        //so.get(so.length - 1).index == alloptions.length - 1 ? so.prev().attr("selected", true) : so.next().attr("selected", true);
                        if ($('#s2').text() == null) {
                            $("#s2").append(so);
                        }
                        if ($('#s2').text() != null) {
                            if ($('#s2').text().indexOf(so.val()) == -1) {
                                $("#s2").append(so);
                            }
                            else {
                                so.remove();
                            }
                        }
                    }
                }
                var strings = '';
                $('#s2 option').each(function() {
                    strings = strings + $(this).val() + ',';
                });

                $('#hih_right').attr('value', strings);
            });
            //选中左移
            $("#remove").click(function() {
                var alloptions = $("#s2 option");
                if (alloptions.length > 0) {
                    var so = $("#s2 option:selected");
                    if (so.length > 0) {
                        //so.get(so.length - 1).index == alloptions.length - 1 ? so.prev().attr("selected", true) : so.next().attr("selected", true);
                        if ($('#s1 option').length == 0) {
                            $("#s1").append(so);
                        }
                        else {
                            if ($('#s1').text().indexOf(so.val()) == -1) {
                                $("#s1").append(so);
                            }
                            else {
                                so.remove();
                            }
                        }
                    }
                }
                var strings = '';
                $('#s2 option').each(function() {
                    strings = strings + $(this).val() + ',';
                });

                $('#hih_right').attr('value', strings);
            });
            //全部右移
            $("#addall").click(function() {
                if ($("#s1").text() != null) {
                    //$("#s1").eq(0).selectedIndex = 0;
                    if ($("#s2 option").length == 0) {
                        //alert($("#s2").text());
                        $("#s2").append($("#s1 option"));
                    }
                    if ($("#s2").text() != null) {
                        var flag = false;
                        $("#s1 option").each(function() {
                            if ($("#s2").text().indexOf($(this).val()) == -1) {
                                $("#s2").append($(this));
                            }
                            else {
                                $(this).remove();
                            }
                        });
                    }
                    $("#s1").val(null);
                }
                var strings = '';
                $('#s2 option').each(function() {
                    strings = strings + $(this).val() + ',';
                });

                $('#hih_right').attr('value', strings);
                $("#s1").empty();
                $("#s1").html('');
            });
            //全部左移
            $("#removeall").click(function() {
                if ($("#s2").text() != null) {
                    if ($("#s1").text() == null) {
                        $("#s1").append($("#s2 option"));
                    }
                    if ($("#s1").text() != null) {
                        var flag = false;
                        $("#s2 option").each(function() {
                            var s2o = $(this);
                            if ($("#s1").text().indexOf(s2o.val()) == -1) {
                                $("#s1").append(s2o);
                            }
                            else {
                                s2o.remove();
                            }
                        });
                    }
                    $("#s2").empty();
                }
                var strings = '';
                $('#s2 option').each(function() {
                    strings = strings + $(this).val() + ',';
                });

                $('#hih_right').attr('value', strings);
            });
        });

    </script>

    </script>
</head>
<body>
    <form id="form1" runat="server">
    <%--<input type="hidden" id="hih_right" value="" runat="server" />--%>
    <asp:HiddenField ID="hih_right" runat="server" Value=""/>
    <!--第一行-->
    <div class="position_list">
        <div class="position_left_list">
        </div>
        <div class="position_con_list">
            <table border="0" cellpadding="0" cellspacing="0">
                <tr>
                    <td width="30">
                        <img src="../../../Images/3G/icon21.gif" width="14" height="14" alt="" />
                    </td>
                    <td class="cyan12">
                        新增自定义组
                    </td>
                </tr>
            </table>
        </div>
        <div class="position_right_list">
        </div>
    </div>
    <!--系统温馨提示栏-->
    <div class="search_list">
        <div class="search_top_list">
            <div class="search_topleft_list">
            </div>
            <!--  查询     -->
            <div class="search_topbg_list">
                <table border="0" cellpadding="0" cellspacing="0">
                    <tr>
                        <td width="30" align="left" valign="middle" style="padding-top: 4px;">
                            <img src="../../../Images/3G/icon_logo.gif" width="22" height="22" />
                        </td>
                        <td width="100" class="cyan13_bold" style="padding-top: 5px;">
                            系统温馨提示栏
                        </td>
                        <td style="padding-top: 5px;">
                            &nbsp;&nbsp;&nbsp;
                        </td>
                    </tr>
                </table>
            </div>
            <div class="search_topright_list">
            </div>
        </div>
    </div>
    <!--   查询条件    -->
    <div class="index_search_con_list">
        <table border="0" cellpadding="0" cellspacing="0" bordercolor="#0e62a7" style="width: 100%;">
            <tr style="padding:7px;">
                <td style="text-align: right; vertical-align: middle">
                    <span style="color: White; font-weight: bold;">自定义组名称：</span>
                </td>
                <td colspan="2">
                    <asp:TextBox ID="txtDefineName" runat="server" Width="335px" MaxLength="20" style="border:1px solid #ffffff; margin-left:-7px;"></asp:TextBox>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="请输入自定义组名称" ControlToValidate="txtDefineName" Display="Dynamic"></asp:RequiredFieldValidator>
                </td>
            </tr>
            <tr style="padding:7px;">
                <td style="text-align: right; vertical-align: middle">
                    <span style="color: White; font-weight: bold;">自定义组成员：</span>
                </td>
                <td valign="top" style="background-color: White">
                    <asp:TreeView ID="tvContactsGroup" runat="server" ImageSet="Arrows" ShowLines="True">
                        <ParentNodeStyle Font-Bold="False" />
                        <HoverNodeStyle Font-Underline="False" ForeColor="#5555DD" />
                        <SelectedNodeStyle Font-Underline="False" HorizontalPadding="0px" VerticalPadding="0px"
                            ForeColor="#5555DD" Font-Bold="true" />
                        <RootNodeStyle ForeColor="Blue" />
                        <NodeStyle Font-Names="Tahoma" Font-Size="10pt" ForeColor="Black" HorizontalPadding="5px"
                            NodeSpacing="0px" VerticalPadding="0px" />
                    </asp:TreeView>
                </td>
                <td valign="top">
                    <!--查询框-->
                    <table border="0" cellpadding="0" cellspacing="0">
                        <tr>
                            <td>
                                <span style="color: White;">查询选项：</span>
                                <asp:DropDownList ID="ddlSearchType" runat="server">
                                    <asp:ListItem Selected="True" Value="CT_Name">姓名</asp:ListItem>
                                    <asp:ListItem Value="CT_Mobile">手机号码</asp:ListItem>
                                </asp:DropDownList>
                                <asp:TextBox ID="txtCondition" runat="server" Style="border: 1px solid #000000; width: 120px"
                                    MaxLength="11"></asp:TextBox>
                                <input type="button" id="btnSearch" runat="server" title="查询" style="width: 61px;
                                    height: 21px; border: 0px; background: url(../../../Images/3G/button_search.gif) no-repeat;" />
                                <%--<asp:Button ID="btnConfirm" runat="server" ToolTip="确认选择" OnClick="btnConfirm_Click" />--%>
                            </td>
                        </tr>
                    </table>
                    <table border="0" cellpadding="0" cellspacing="0">
                        <tr>
<%--                            <td>
                                <div id="divData">
                                    <table>
                                        <tr>--%>
                                            <td style="vertical-align: top">
                                                <span style="color: White;">联系人</span>
                                                <br />
                                                <asp:ListBox ID="s1" runat="server" Height="250px" Width="175px" SelectionMode="Multiple" >
                                                </asp:ListBox>
                                            </td>
                                            <td style="vertical-align: middle">
                                                <input type="button" id="addall" runat="server" title="全部右移" />
                                                <br />
                                                <input type="Button" id="add" runat="server" title="右移" />
                                                <br />
                                                <input type="Button" id="remove" runat="server" title="左移" />
                                                <br />
                                                <input type="Button" id="removeall" runat="server" title="全部左移" />
                                            </td>
                                            <td>
                                                <span style="color: White;">已选择组成员</span>
                                                <br />
                                                <asp:ListBox ID="s2" runat="server" Height="250px" Width="175px" SelectionMode="Multiple" >
                                                </asp:ListBox>
                                                <select id="s3" style="display: none" />
                                                &nbsp;&nbsp;&nbsp;&nbsp;
                                            </td>
                                        </tr>
                                    <%--</table>
                                </div>
                            </td>
                        </tr>--%>
                    </table>
                   
                </td>
            </tr>
            <tr style="padding:7px;">
                <td colspan="3">
                    <asp:Button ID="btnAdd" runat="server" Text="" OnClick="btnAdd_Click" />
                    <asp:Button ID="btnBack" runat="server" Text="" onclick="btnBack_Click" CausesValidation="false"/>
                </td>
            </tr>
        </table>
    </div>
    <div class="search_bottom_list">
        <div class="search_bottomleft_list">
        </div>
        <div class="search_bottombg_list">
        </div>
        <div class="search_bottomright_list">
        </div>
    </div>
    </form>
</body>
</html>
